

var piUploadStatus = { 
    "0": "None",
    "1": "UploadInvalid",
    "2": "UploadValid",
    "3": "AppliedStart",
    "4": "AppliedSuccess",
    "5": "AppliedFailure",
    "6": "Canceled",
}

function isNumeric(n){
   return !isNaN(parseFloat(n)) && isFinite(n);
}

var collection = db.getSiblingDB("ClientPlatform").PIInputFile
collection.find({}).forEach(function(item){

    item.History.forEach(function(subitem){
        if (isNumeric(subitem.Status))
            subitem.Status = piUploadStatus[subitem.Status];
    })
})

